/*
 * GeoVISTA Center (Penn State, Dept. of Geography)
 * Copyright (c), 2003-2011,  Jin Chen and Alan M. MacEachren, GeoVISTA Center, Penn State University
 * All Rights Researved.
 *
 * This library is developed and distributed for free usage,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 * You can redistribute and/or modify it under the terms of the
 * Simplified BSD License
 *
 *
 *
 *
 *
 *
 *
 * As a standalone component, the previous version of dataloader has its own datapath. This version dataloader take wizard format,
 * and PathsPane is just a page in wizard to show dataloader's pathPane. It acutally get the pathPane of dataloader and display it
 * @Original Author: jin Chen
 * @date: Apr 15, 2004$
 * @version: 1.0
 */
package edu.psu.geovista.app.dataloader.v1.gui;

import edu.psu.geovista.app.dataloader.v1.DataLoaders;
import edu.psu.geovista.ui.dataloader.common.FileLoadingPane;
import epoviz.trex.common.swing.layout.UnevenRowSectionPane;

import javax.swing.*;
import javax.swing.border.TitledBorder;
import java.awt.*;

public class PathsPane extends BasicPane {

    public PathsPane(DataLoaders dataloader) {
        super(dataloader);

        showPcpTs();//by default show both
    }




    public void showPcpOnly(){
        this.removeAll();
         this.setLayout(new BorderLayout());
        FileLoadingPane pcppane = this.getPcpPane();
        this.add( pcppane);//new JLabel("Teset lable"));
        this.add(this.getControlPane(),BorderLayout.SOUTH );
        this.setBorder(new TitledBorder("test border"));

        this.revalidate() ;
    }
    public void showTsOnly() {
        this.removeAll();
         this.setLayout(new BorderLayout());
        this.add(this.getTsPane() );
        this.add(this.getControlPane(),BorderLayout.SOUTH );
        this.revalidate() ;
    }
    public void showPcpTs() {
        this.removeAll();
         this.setLayout(new BorderLayout());
         //main pane
         JPanel pcppath=this.getPcpPane() ;
         JPanel tspath=this.getTsPane() ;

         UnevenRowSectionPane p=new UnevenRowSectionPane();
         p.clearMainPane();
         p.removeControlPane();

        

         JComponent[] comps=new JComponent[]{pcppath,tspath};
         double[] ws=new double[]{3.5,2};
         p.addToMainPane(comps,ws);
        

         //put them together
         this.add(p);
         this.add(this.getControlPane(),BorderLayout.SOUTH  ) ;
          this.revalidate() ;
    }

    protected  FileLoadingPane getPcpPane(){
        FileLoadingPane pcppath=this.pcpload.getDataPathPane();
        Component[] components = pcppath.getComponents();
        TitledBorder pcpBorder = new TitledBorder("Primary Data Paths");
        TitledBorder testBorder = new TitledBorder("Test Primary Data Paths");

         pcpBorder.setTitleColor(DataLoaders.COLOR_SECTION_TITLE );
         pcpBorder.setTitleFont(DataLoaders.FONT_SECTION_TITLE );
         pcppath.setFileSrcBorder(testBorder);
         return pcppath;
    }
    protected FileLoadingPane getTsPane(){
         FileLoadingPane tspath=this.tsload.getDataPathPane();
        TitledBorder tsBorder = new TitledBorder("Time Series Data Paths");
        tsBorder.setTitleColor(DataLoaders.COLOR_SECTION_TITLE );
        tsBorder.setTitleFont(DataLoaders.FONT_SECTION_TITLE );
        tspath.setFileSrcBorder(tsBorder);
        return tspath;
    }
    

    /*private void setGUI(){
        FileLoadingPane pcppath=this.pcpload.getDataPathPane();
         TitledBorder pcpBorder = new TitledBorder("Pcp data paths");
         pcpBorder.setTitleColor(Color.BLUE );
         pcppath.setFileSrcBorder(pcpBorder);

         FileLoadingPane tspath=this.tsload.getDataPathPane();
        TitledBorder tsBorder = new TitledBorder("Time series data paths");
        tsBorder.setTitleColor(Color.BLUE );
        tspath.setFileSrcBorder(tsBorder);


         UnevenRowSectionPane p=new UnevenRowSectionPane();
         p.clearMainPane();


         JComponent[] comps=new JComponent[]{pcppath,tspath};
         double[] ws=new double[]{3.5,2};
         p.addToMainPane(comps,ws);


         JButton custBtn=new JButton();
         BasicAction selattr=this.getAction(ActionManager.Act_SelectAttrs);
         custBtn.setAction(selattr);
         custBtn.setText("Pick variables");


         JButton okBtn=new JButton();
         BasicAction autoselattr=this.getAction(ActionManager.Act_AutoSelectLoad);
         okBtn.setAction(autoselattr );
         okBtn.setText("OK");

         JButton backBtn=new JButton("Choose another project");
            backBtn.addActionListener(new ActionListener(){
                public void actionPerformed(ActionEvent e){
                    cleanDataSource();
                    showProjectDlg();

                }
            });


         p.clearControlPane() ;
         p.addToControlPane(backBtn);
         p.addToControlPane(custBtn);
         p.addToControlPane(okBtn);
         p.revalidate() ;
    }*/
}
